<template>
    <div>
 
         <table>
            <tr>
                <td>名称</td>
                <td>
                    <input type="text" v-model="sz.Yname">
                </td>
            </tr>
            <tr>
                <td>等级</td>
                <td>
                     <input type="text" v-model="sz.Ydj">
                </td>
            </tr>
            <tr>
                <td>数量</td>
                <td>
                     <input type="text" v-model="sz.Ysl">
                </td>
            </tr>
            <tr>
                <td>渠道</td>
                <td>
                     <input type="text" v-model="sz.Yqd">
                </td>
            </tr>
            <tr>
                <td>照片</td>
                <td>
                    <input type="file" @change="zhaopian">
                    <img :src="'https://localhost:7057'+sz.Ytp" style="height: 60px;width: 60px;">
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="添加" @click="add">
                </td>
            </tr>
         </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios'
import {ref,onMounted} from 'vue'

const zhaopian = (ev:any)=>{
    let f = ev.target.files[0];
    let fd = new FormData();
    fd.append("file",f);


    axios.post("https://localhost:7057/api/RK/shangchuan",fd).then((res)=>{
        sz.value.Ytp = res.data;
    })
}

const sz = ref({
  "Yid": 0,
  "Yname": "string",
  "Ydj": "string",
  "Ysl": "string",
  "Yqd": "string",
  "Ytp": "string"
})

const add=()=>{
    axios.post("https://localhost:7057/api/RK/Add").then(res=>{
        sz.value = res.data;
    })
}
</script>

<style scoped>

</style>